import axiosRequest from '../index'
import { IAccount, ILoginResult } from './types'
import { IDataType } from '../types'

enum LoginAPI {
  AccountLogin = '/login',
  LoginUserInfo = '/users/', //用法：/users/1
  UserMenus = '/role/' //用法：role/1/menu
}

export function postAccountLogin(account: IAccount) {
  return axiosRequest.post<IDataType<ILoginResult>>({
    url: LoginAPI.AccountLogin,
    data: account
  })
}

export function getUserInfoById(id: number) {
  return axiosRequest.get<IDataType>({
    url: LoginAPI.LoginUserInfo + id
  })
}

export function getUserMenusByRoleId(id: number) {
  return axiosRequest.get<IDataType>({
    url: LoginAPI.UserMenus + id + '/menu'
  })
}
